#pragma once

// forward declarations
class ContourDot;
class Stroke;
namespace Gdiplus { class GraphicsPath; };

class Curve
{
	float mAx, mAy, mM1x, mM1y, mM2x, mM2y, mBx, mBy;

	const Stroke* mOwnerStroke; // weak link
	int mStrokeEnd;

public:
	Curve(const ContourDot& dot1, const ContourDot& dot2, 
		const Stroke* stroke = NULL, int strokeEnd = 0);

	// creates a curve (arc of circle) at the end of stroke
	Curve(const Stroke* stroke, int strokeEnd);

	// create curve from some arbitrary point to the dot at the end of stroke
	Curve(float x, float y, float vx, float vy, const Stroke*, int strokeEnd);

	void AddToPath(Gdiplus::GraphicsPath* outPath) const;

	void GetPointAtParameter(float t, float& outX, float& outY) const;
	void GetDirectionAtParameter(float t, float& outVx, float& outVy) const;
	const Stroke* GetStroke() const;
	int GetStrokeEnd() const;

	bool AreDotsSeparated(const ContourDot& dot1, const ContourDot& dot2) const;

	// returns either found parameter t from the range (0..1) or -1 on failure
	float FindParameterAimedByContourDot(const ContourDot&, 
		bool reverseDotDirection) const;
};

